<% layout('/layouts/default.html', {title: '发布版本', libs: ['validate','fileupload']}){ %>
<div class="main-content">

	<div class="box box-main">

		<div class="box-body">

			<div class="col-xs-12 gg" >
				<div style="width: 34%">
					<span style="color: red">*</span>
					指标体系版本名称：
				</div>
				<#form:hidden path="versionNumber" value="${dcSupExamSumQuota.versionNumber}" />
				<#form:hidden path="examId" value="${dcSupExamSumQuota.examId}" />
				<#form:hidden path="remarks2" value="${dcSupExamSumQuota.remarks2}" />
				<#form:input path="versionName"  class="form-control required" placeholder="请在此处输入版本名称"/>

			</div>
		</div>
		<div class="box-footer">
			<div class="row" >
				<div class="col-sm-offset-2 col-sm-10">
					<button type="button" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('确 定')}</button>&nbsp;
					<button  class="btn btn-sm btn-default" id="btnCancel" ><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
				</div>
			</div>
		</div>

</div>
</div>
<% } %>
<style>
	.gg{
		margin: 20% 0px 20% 0px ;
		display: flex;
		align-items: center;
		justify-content: center;
	}
</style>
<script>
	$("#inputForm").validate({
		submitHandler: function(form){
			js.ajaxSubmitForm($(form), function(data){
				js.showMessage(data.message);
				if(data.result == Global.TRUE){
					js.closeCurrentTabPage(function(contentWindow){
						contentWindow.page();
					});
				}
			}, "json");
		}
	});
	$("#btnCancel").click(function (){
		var index = parent.layer.getFrameIndex(window.name);
		parent.layer.close(index);
	})

	$("#btnSubmit").click(function (){
		var versionNumber = $("#versionNumber").val();
		var examId = $("#examId").val();
		var remarks2 = $("#remarks2").val();
		var versionName = $("#versionName").val();
		if (versionName == '') {
			js.showMessage("版本名称不能为空");
			return;
		}
			// 获取选择的id;
			js.ajaxSubmit({
				url: "${ctx}/quota/dcSupExamSumQuotaInfo/saveVersion",
				data: {"versionNumber": versionNumber, "examId": examId,"remarks2":remarks2,"versionName":versionName},
				dataType: 'json',
				callback: function (data) {
					if (data.result == "true") {
						js.showMessage("保存版本成功");
						$(parent.document.getElementById("mainVersion")).val(data.message);
						var index = parent.layer.getFrameIndex(window.name);
						parent.layer.close(index);
					} else {
						js.showMessage(data.message);
					}
				}
			})
	})
</script>